1
|
|
|
/* |
2
|
|
|
* Circles - Bring cloud-users closer together. |
3
|
|
|
* |
4
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
5
|
|
|
* later. See the COPYING file. |
6
|
|
|
* |
7
|
|
|
* @author Maxence Lange <[email protected]> |
8
|
|
|
* @copyright 2017 |
9
|
|
|
* @license GNU AGPL version 3 or any later version |
10
|
|
|
* |
11
|
|
|
* This program is free software: you can redistribute it and/or modify |
12
|
|
|
* it under the terms of the GNU Affero General Public License as |
13
|
|
|
* published by the Free Software Foundation, either version 3 of the |
14
|
|
|
* License, or (at your option) any later version. |
15
|
|
|
* |
16
|
|
|
* This program is distributed in the hope that it will be useful, |
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19
|
|
|
* GNU Affero General Public License for more details. |
20
|
|
|
* |
21
|
|
|
* You should have received a copy of the GNU Affero General Public License |
22
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
23
|
|
|
* |
24
|
|
|
*/ |
25
|
|
|
|
26
|
|
|
/** global: OC */ |
27
|
|
|
/** global: OCA */ |
28
|
|
|
/** global: Notyf */ |
29
|
|
|
|
30
|
|
|
/** global: nav */ |
31
|
|
|
/** global: elements */ |
32
|
|
|
/** global: curr */ |
33
|
|
|
/** global: api */ |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
var nav = { |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
|
40
|
|
|
initNavigation: function () { |
41
|
|
|
this.initElementsMemberNavigation(); |
42
|
|
|
this.initElementsCircleNavigation(); |
43
|
|
|
}, |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
initElementsMemberNavigation: function () { |
47
|
|
|
|
48
|
|
|
elements.addMember.on('input propertychange paste focus', function () { |
49
|
|
|
var search = $(this).val().trim(); |
50
|
|
|
if (search === '') { |
51
|
|
|
elements.membersSearchResult.fadeOut(400); |
52
|
|
|
return; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
actions.searchMembersRequest(search); |
|
|
|
|
56
|
|
|
if (elements.membersSearchResult.children().length === 0) { |
57
|
|
|
elements.membersSearchResult.fadeOut(400); |
58
|
|
|
} else { |
59
|
|
|
elements.membersSearchResult.fadeIn(400); |
60
|
|
|
} |
61
|
|
|
}).blur(function () { |
62
|
|
|
elements.membersSearchResult.fadeOut(400); |
63
|
|
|
}); |
64
|
|
|
}, |
65
|
|
|
|
66
|
|
|
initElementsCircleNavigation: function () { |
67
|
|
|
|
68
|
|
|
elements.joinCircle.on('click', function () { |
69
|
|
|
api.joinCircle(curr.circle, actions.joinCircleResult); |
|
|
|
|
70
|
|
|
}); |
71
|
|
|
|
72
|
|
|
elements.leaveCircle.on('click', function () { |
73
|
|
|
api.leaveCircle(curr.circle, actions.leaveCircleResult); |
|
|
|
|
74
|
|
|
}); |
75
|
|
|
|
76
|
|
|
elements.joinCircleAccept.on('click', function () { |
77
|
|
|
api.joinCircle(curr.circle, actions.joinCircleResult); |
|
|
|
|
78
|
|
|
}); |
79
|
|
|
|
80
|
|
|
elements.joinCircleReject.on('click', function () { |
81
|
|
|
api.leaveCircle(curr.circle, actions.leaveCircleResult); |
|
|
|
|
82
|
|
|
}); |
83
|
|
|
}, |
84
|
|
|
|
85
|
|
|
|
86
|
|
|
displayCirclesList: function (type) { |
87
|
|
|
|
88
|
|
|
curr.circlesType = type; |
89
|
|
|
curr.searchCircle = ''; |
90
|
|
|
curr.searchUser = ''; |
91
|
|
|
|
92
|
|
|
curr.circle = 0; |
93
|
|
|
curr.circleLevel = 0; |
94
|
|
|
|
95
|
|
|
elements.navigation.show('slide', 800); |
96
|
|
|
elements.emptyContent.show(800); |
97
|
|
|
elements.mainUI.fadeOut(800); |
98
|
|
|
|
99
|
|
|
elements.circlesSearch.val(''); |
100
|
|
|
elements.addMember.val(''); |
101
|
|
|
|
102
|
|
|
this.resetCirclesTypeSelection(type); |
103
|
|
|
elements.resetCirclesList(); |
104
|
|
|
api.listCircles(type, actions.listCirclesResult); |
|
|
|
|
105
|
|
|
}, |
106
|
|
|
|
107
|
|
|
|
108
|
|
|
resetCirclesTypeSelection: function (type) { |
109
|
|
|
elements.circlesList.children('div').removeClass('selected'); |
110
|
|
|
elements.circlesList.children().each(function () { |
111
|
|
|
if ($(this).attr('circle-type') == type.toLowerCase()) { |
112
|
|
|
$(this).addClass('selected'); |
113
|
|
|
} |
114
|
|
|
}); |
115
|
|
|
}, |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* |
119
|
|
|
* @param display |
120
|
|
|
*/ |
121
|
|
|
displayOptionsNewCircle: function (display) { |
122
|
|
|
if (display) { |
123
|
|
|
elements.newType.fadeIn(300); |
124
|
|
|
elements.newSubmit.fadeIn(500); |
125
|
|
|
elements.newTypeDefinition.fadeIn(700); |
126
|
|
|
} |
127
|
|
|
else { |
128
|
|
|
elements.newType.fadeOut(700); |
129
|
|
|
elements.newSubmit.fadeOut(500); |
130
|
|
|
elements.newTypeDefinition.fadeOut(300); |
131
|
|
|
} |
132
|
|
|
}, |
133
|
|
|
|
134
|
|
|
|
135
|
|
|
displayMembers: function (members) { |
136
|
|
|
|
137
|
|
|
elements.remMember.fadeOut(300); |
138
|
|
|
elements.rightPanel.fadeOut(300); |
139
|
|
|
|
140
|
|
|
elements.mainUIMembers.emptyTable(); |
141
|
|
|
if (members === null) { |
142
|
|
|
elements.mainUIMembers.hide(200); |
143
|
|
|
return; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
elements.mainUIMembers.show(200); |
147
|
|
|
for (var i = 0; i < members.length; i++) { |
148
|
|
|
var tmpl = elements.generateTmplMember(members[i]); |
149
|
|
|
elements.mainUIMembers.append(tmpl); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
$('tr.entry').on('click', function () { |
153
|
|
|
nav.displayMemberDetails($(this).attr('member-id'), $(this).attr('member-level'), |
154
|
|
|
$(this).attr('member-levelstring'), $(this).attr('member-status')); |
155
|
|
|
}); |
156
|
|
|
}, |
157
|
|
|
|
158
|
|
|
|
159
|
|
|
displayMemberDetails: function (id, level, levelstring, status) { |
160
|
|
|
|
161
|
|
|
level = parseInt(level); |
162
|
|
|
curr.member = id; |
163
|
|
|
curr.memberLevel = level; |
164
|
|
|
curr.memberStatus = status; |
165
|
|
|
|
166
|
|
|
elements.rightPanel.fadeIn(300); |
167
|
|
|
elements.memberDetails.children('#member_name').text(id); |
168
|
|
|
if (level === 0) { |
169
|
|
|
levelstring += ' / ' + status; |
170
|
|
|
} |
171
|
|
|
elements.memberDetails.children('#member_levelstatus').text(levelstring); |
172
|
|
|
|
173
|
|
|
this.displayMemberDetailsAsModerator(); |
174
|
|
|
}, |
175
|
|
|
|
176
|
|
|
|
177
|
|
|
displayMemberDetailsAsModerator: function () { |
178
|
|
|
if (curr.circleLevel >= 6 && curr.memberLevel < curr.circleLevel) { |
179
|
|
|
if (curr.memberStatus == 'Requesting') { |
180
|
|
|
elements.memberRequest.fadeIn(300); |
181
|
|
|
elements.remMember.fadeOut(300); |
182
|
|
|
} |
183
|
|
|
else { |
184
|
|
|
elements.memberRequest.fadeOut(300); |
185
|
|
|
elements.remMember.fadeIn(300); |
186
|
|
|
} |
187
|
|
|
} else { |
188
|
|
|
elements.remMember.fadeOut(300); |
189
|
|
|
elements.memberRequest.fadeOut(300); |
190
|
|
|
} |
191
|
|
|
}, |
192
|
|
|
|
193
|
|
|
|
194
|
|
|
displayCircleDetails: function (details) { |
195
|
|
|
elements.circlesDetails.children('#name').text(details.name); |
196
|
|
|
elements.circlesDetails.children('#type').text(details.typeLongString); |
197
|
|
|
}, |
198
|
|
|
|
199
|
|
|
|
200
|
|
|
displayMembersInteraction: function (details) { |
201
|
|
|
if (details.user.level < 6) { |
202
|
|
|
elements.addMember.hide(); |
203
|
|
|
} else { |
204
|
|
|
elements.addMember.show(); |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
elements.joinCircleInteraction.hide(); |
208
|
|
|
this.displayNonMemberInteraction(details); |
209
|
|
|
|
210
|
|
|
if (details.user.level == 9) { |
211
|
|
|
elements.joinCircle.hide(); |
212
|
|
|
elements.leaveCircle.hide(); |
213
|
|
|
return; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
if (details.user.level >= 1) { |
217
|
|
|
elements.joinCircle.hide(); |
218
|
|
|
elements.leaveCircle.show(); |
219
|
|
|
} |
220
|
|
|
}, |
221
|
|
|
|
222
|
|
|
|
223
|
|
|
displayNonMemberInteraction: function (details) { |
224
|
|
|
elements.joinCircleAccept.hide(); |
225
|
|
|
elements.joinCircleReject.hide(); |
226
|
|
|
elements.joinCircleRequest.hide(); |
227
|
|
|
elements.joinCircleInvite.hide(); |
228
|
|
|
|
229
|
|
|
if (details.user.status == 'Invited') { |
230
|
|
|
this.displayInvitedMemberInteraction(); |
231
|
|
|
return; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
if (details.user.status == 'Requesting') { |
235
|
|
|
this.displayRequestingMemberInteraction(); |
236
|
|
|
return; |
237
|
|
|
} |
238
|
|
|
|
239
|
|
|
elements.joinCircle.show(); |
240
|
|
|
elements.leaveCircle.hide(); |
241
|
|
|
}, |
242
|
|
|
|
243
|
|
|
|
244
|
|
|
displayInvitedMemberInteraction: function () { |
245
|
|
|
elements.joinCircleInteraction.show(); |
246
|
|
|
elements.joinCircleInvite.show(); |
247
|
|
|
elements.joinCircleAccept.show(); |
248
|
|
|
elements.joinCircleReject.show(); |
249
|
|
|
elements.joinCircle.hide(); |
250
|
|
|
elements.leaveCircle.hide(); |
251
|
|
|
}, |
252
|
|
|
|
253
|
|
|
displayRequestingMemberInteraction: function () { |
254
|
|
|
elements.joinCircleInteraction.show(); |
255
|
|
|
elements.joinCircleRequest.show(); |
256
|
|
|
elements.joinCircle.hide(); |
257
|
|
|
elements.leaveCircle.show(); |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
}; |
261
|
|
|
|
262
|
|
|
|
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.